Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Apply some dockerfile best practices #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sbellem
Copy link

@sbellem sbellem commented Aug 3, 2023

  • use COPY instead of ADD
  • run apt-get update before apt-get install to refresh the cache
  • clear up the apt cache (/var/lib/apt/lists) to reduce the image size

Some Dockerfile best practices links

ADD or COPY

For other items, like files and directories, that don’t require the tar auto-extraction capability of ADD, you should always use COPY.

apt-get

Always combine RUN apt-get update with apt-get install in the same RUN statement.

In addition, when you clean up the apt cache by removing /var/lib/apt/lists it reduces the image size, since the apt cache isn’t stored in a layer. Since the RUN statement starts with apt-get update, the package cache is always refreshed prior to apt-get install.

Sort multi-line arguments

* use COPY instead of ADD
* run apt-get update before apt-get install to refresh the cache
* clear up the apt cache (/var/lib/apt/lists) to reduce the image size
@dartdart26
Copy link
Collaborator

@david-zama Could you please have a look?

@dartdart26
Copy link
Collaborator

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Aug 23, 2023

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @sbellem on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@cla-bot
Copy link

cla-bot bot commented Aug 23, 2023

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants